//||=========================================================================||
//||                                                                         ||
//||                              MainWindow.h                               ||
//||                                                                         ||
//||                           by the_best_goose))                           ||
//||                                                                         ||
//||=========================================================================||

//-----------------------------------------------------------------------------
//! \file MainWindow.h
//! It declares MainWindow class and its members.
//! \brief Header of MainWindow class.

#include <QMainWindow>
#include <QCloseEvent>
#include <QLabel>
#include <string>
#include <QSlider>
#include <QLayout>
#include "TemplateMakers.h"

using std::string;

#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_

//-----------------------------------------------------------------------------
//! This class contains all program menus to watch and set parameters of
//! Mandelbrot Set showing. This class uses QT signals to set up parameters to
//! object this IMandelbrotWgt interface. All parameters can be changed from
//! menu or using appropriate hot keys.
//! \brief It contains TBG-Fractal main window and manages program execution.

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    //! Constructs all menus and starts showing fractal.
    //! \brief Constructor of main window class.
    MainWindow(MandelbrotWgtMaker pmand, //!< Pointer to any widget which should
    		   //! show fractals
    		   QWidget* pwgt = 0 //!< Pointer to the base object in QT object
    		   //!< hierarchy.
    		   );

    //! Sends QT signal Deleted.
    //! \brief Destructor of main window class.
    ~MainWindow();

public slots:
    //! Shows information about this program and its author.
    //! \brief Treater of menu about click event.
    void About();
//    void CreateJulia();
//    void JuliaKilled();

    //! Asks user for iterations count and sends signal
    //! IterationsCountChanged(int count) with this information.
    //! \brief Treater of menu set iterations count click event.
    void SetItersCount();

    //! Asks user for real part of T and sends signal
    //! TReChanged(float t_re) with this information.
    //! \brief Treater of menu set real part of T parameter click event.
    void SetTRe();

    //! Asks user for imaginary part of T and sends signal
    //! TImChanged(float t_im) with this information.
    //! \brief Treater of menu set imaginary part of T parameter click event.
    void SetTIm();

    //! Asks user for the mapping in string format, validates it and sends
    //! MappingChanged(string mapping) signal with this information.
    //! \brief Treater of menu set mapping click event.
    void SetMapping();

    //! Fractal widget or other object should connect its signal to this slot
    //! for correct Julia set imagine.
    //! \brief Slot for julia pointer coord updating.
    void SetJuliaPointer(QPointF point);

signals :
    //! Sends when someone deletes or closes main window of TBG-Fractal.
    void Deleted();

    //! \brief Sends when someone changes fractal mapping
    void MappingChanged(string mapping);

    //! \brief Sends when someone changes iterations count
    void IterationsCountChanged(int count);

    //! \brief Sends when someone changes real part of T parameter
    void TReChanged(float t_re, bool need_recount = true);

    //! \brief Sends when someone changes imaginary part of T parameter
    void TImChanged(float t_im, bool need_recount = true);

private :

    void CreateActions();
    void CreateMenus();
    void CreateToolBars();
    void CreateStatusBar();

    QMenu* file_menu_;
    QMenu* help_menu_;
    QMenu* view_menu_;
    QMenu* mandelbrot_menu_;

    QAction* exit_act_;
    QAction* about_act_;
    QAction* about_qt_act_;
    QAction* create_julia_act_;
    QAction* set_iters_count_act_;
    QAction* set_mapping_act_;
    QAction* set_t_re_act_;
    QAction* set_t_im_act_;

    QWidget* pmandelbrot_;
    MainWindow* pjulia_wind_;

    QString mapping_;
    float t_re_;
    float t_im_;
    int iters_count_;

};

//-----------------------------------------------------------------------------

#endif // MAINWINDOW_H_
